using System;

namespace AleaClasses
{
	/// <summary>
	/// This is a base class for classes that need to implement ITrackEdits, which
	/// packages up a lot of the necessary functionality.
	/// </summary>
	public class TTrackEdits: ITrackEdits
	{
		bool fNeedsSave = false;

		public bool NeedsSave()
		{
			return fNeedsSave || ChildrenNeedSave();
		}

		protected virtual bool ChildrenNeedSave()
		{
			// stub does nothing but can override
			return false;
		}

		public void ClearNeedsSave()
		{
			fNeedsSave = false;
			ClearChildrenNeedsSave();
		}

		protected virtual void ClearChildrenNeedsSave()
		{
			// stub does nothing, can override
		}

		protected void SetNeedsSave()
		{
			fNeedsSave = true;
		}
	}
}
